package com.tangsm.spring.boot.strategy.demo.biz;

import com.tangsm.spring.boot.strategy.demo.annotation.MessageTransports;
import com.tangsm.spring.boot.strategy.demo.base.SendMessageSuper;
import com.tangsm.spring.boot.strategy.demo.domain.Message;
import com.tangsm.spring.boot.strategy.demo.enums.MessageTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * SMS-短信消息策略业务实现
 * @author tangsm
 */
@MessageTransports(MessageTypeEnum.EMAIL)
@Service
public class EmailSendMessageSub extends SendMessageSuper {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;
    /**
     * 各通道策略业务实现
     * @param message 消息参数
     */
    @Override
    protected void transportBusiness(Message message) {
        String msg = String.format("SendEmailMessage：%s发送%s成功",
                message.getTarget(),
                MessageTypeEnum.getNameByCode(message.getType()));
        log.info(msg);
    }

    /**
     * 初始化 redisTemplate对象
     */
    @Override
    protected RedisTemplate<String, String> setRedisTemplate() {
        return redisTemplate;
    }
}
